<%= form_for(@user, :url => {:controller => 'users', :action => 'update', :id => @user.id}, :html => {:class => 'form-horizontal', :multipart => true, :data => {:abide => true}}) do |f| %>
    <div class="form-content form-below">
      <% if @user.errors.any? %>
          <div id="error_explanation">
            <% @user.errors.full_messages.each do |msg| %>
                <li><%= msg %></li>
            <% end %>
            </ul>
          </div>
      <% end %>

      <% if current_user.manager? %>
          <%= build_validated_field('user', 'name', 'Name', 'Cannot be blank', '[a-zA-Z]+', 'text', @user.name) %>
          <% if current_user == @user %>
              <%= build_validated_field('user', 'nickname', 'Nickname', 'Cannot be blank', '[a-zA-Z]+', 'text', @user.nickname) %>
              <%= build_field('user', 'image', 'Profile picture', 'file', @user.image) %>
          <% end %>
          <%= build_validated_field('user', 'email', 'Email', '', '', 'text', @user.email) %>
          <%= build_validated_field('user', 'employee_code', 'Employee code', 'Cannot be blank', '[a-zA-Z]+', 'text', @user.employee_code) %>
          <%= build_validated_select('user', 'role', 'Role', 'Should select at least one', '', false, @user_role, [['Employee'], ['Manager']]) %>
          <%#= build_validated_field('user', 'password', 'Password', '', '','password',@user.password) %>
          <%#= build_validated_field('user', 'password_confirmation', 'Confirm password', '', '','password',@user.password_confirmation) %>
          <div class='form-row'>
            <div class='small-3 columns'>
              <%= f.label :manager_ids %>
            </div>
            <div class='small-9 columns'>
              <%= f.select :manager_ids, @users.map { |x| [x.name, x.id] }, {}, {:multiple => true} %>
            </div>
          </div>
      <% end %>
      <% if current_user == @user %>
          <% unless current_user.manager? %>
          <%= build_validated_field('user', 'nickname', 'Nickname', 'Cannot be blank', '[a-zA-Z]+', 'text', @user.nickname) %>
          <%= build_field('user', 'image', 'Profile picture', 'file', @user.image) %>
      <% end %>
<% end %>
</div>

<div class="small-12 columns form-action-up">
  <div class="title">Edit user</div>
  <div class="right">
    <%= f.submit "Save", :class => 'button alert right' %>
    <%= link_to t('.cancel', :default => t("helpers.links.cancel")),
                user_path(@user), :class => 'btn cancel-btn' %>
  </div>
</div>
<% end %>
<script type="text/javascript">
    window.location = '#pane3'
</script>
